package com.raymond.cmpp.client.handler;

import com.raymond.cmpp.client.CmppClient;
import com.raymond.cmpp.common.msg.response.ConnectResponseMessage;
import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 连接响应处理
 *
 * @author :  raymond
 * @version :  V1.0
 * @date :  2021-08-05 15:47
 */
public class ConnectResponseMessageHandler extends BaseBusinessHandler<ConnectResponseMessage> {

    private final static Logger logger = LoggerFactory.getLogger(ConnectResponseMessageHandler.class);

    public ConnectResponseMessageHandler(CmppClient queueClient) {
        super(ConnectResponseMessage.class, queueClient);
    }

    @Override
    protected void channelRead(ChannelHandlerContext ctx, ConnectResponseMessage msg) throws Exception {
        logger.info("连接响应:{}", msg);
        if (msg.getStatus() == 0) {
            cmppClient.connectSuc();
        }
        responseNotice(msg);
    }
}
